package com.yz.fanrenmianshi.mapper;

import com.yz.fanrenmianshi.model.entity.QuestionFavour;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
* @author K4s1ana
* @description 针对表【question_favour(题目收藏表)】的数据库操作Mapper
* @createDate 2025-09-29 11:18:47
* @Entity com.yz.fanrenmianshi.model.entity.QuestionFavour
*/
public interface QuestionFavourMapper extends BaseMapper<QuestionFavour> {

        /**
         * 查询包括已被逻辑删除的数据
         */
        @Select("SELECT * FROM question_favour WHERE questionId = #{questionId} AND userId = #{userId} AND isDelete = 1")
        QuestionFavour listDeletedFavour(@Param("questionId") Long questionId, @Param("userId") Long userId);

        /**
         * 恢复逻辑删除的记录
         */
        @Update("UPDATE question_favour SET isDelete = 0, updateTime = #{updateTime} WHERE id = #{id}")
        int restoreDeletedFavour(@Param("id") Long id, @Param("updateTime") Date updateTime);

        /**
         * 逻辑删除
         */
        @Update("UPDATE question_favour SET isDelete = 1, updateTime = #{updateTime} WHERE id = #{id}")
        int deleteFavour(@Param("id") Long id, @Param("updateTime") Date updateTime);

}